package top.hudk.jdk8;

import java.util.Date;
import java.util.Optional;

/**
 * 功能或业务描述：
 * 创建时间：2021/6/18 9:01
 * 作者：hudk
 */
public class OptionalTest {

    public static void main(String[] args) {

        User user = new User();

        Long time = Optional.ofNullable(user).map(User::getBirth).map(Date::getTime).orElse(null);
        //user.getBirth().getTime();
        System.out.println(time);

    }


    public static class User{
        private String name;

        private Date birth;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public Date getBirth() {
            return birth;
        }

        public void setBirth(Date birth) {
            this.birth = birth;
        }
    }

}
